# -*- coding: utf-8 -*-

from PyQt4.QtGui import QDialog
from PyQt4.QtCore import SIGNAL
from PyQt4.Qt import QRect, QDesktopWidget
from ui_testcsvwindow import Ui_TestCsvWindow
from subprocess import *
from mainfunctions import *

class TestCsvWindow(QDialog):
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.ui = Ui_TestCsvWindow()
        self.ui.setupUi(self)
        self.browser = None
        available_geom = QDesktopWidget().availableGeometry()
        current_geom = self.frameGeometry()
        self.setGeometry(available_geom.width() / 2 - current_geom.width() / 2, available_geom.height() / 2 - current_geom.height() / 2, current_geom.width(), current_geom.height());
        
        self.connect(self.ui.generateTestCsvButton, SIGNAL("clicked()"), self.generateTestCsvFile)

    def generateTestCsvFile(self):
        self.hide()

        createTest(self.browser, self.ui.startDate.dateTime().toString("yyyy-MM-dd"),
                   self.ui.endDate.dateTime().toString("yyyy-MM-dd"),
                   self.ui.lastReleaseDate.dateTime().toString("yyyy-MM-dd"))
    
